const Koa = require("koa");
const koaBody = require("koa-body");
const static = require('koa-static')
const cors = require('koa-cors')

let router = require("./router.js");

const app = new Koa();

app.use(koaBody());

// 设置跨域 用不用插件都可
app.use(async (ctx, next) => {
  ctx.set("Access-Control-Allow-Origin", "*");
  return next();
});
// app.use(cors())

app.use(router.routes());

// app.use(static(path.join(__dirname)))


// 监听3001端口
app.listen(3001, () => {
  console.log("server run on 127.0.0.1:3001");
});
